<?php
namespace User\Controller;
use Think\Controller;
class IndexController extends Controller {


	//登陆首页
    public function index(){
	
		if (CheckLoginWeb()) {
		
			$this->redirect('Center/index', array() , 0, '');
		}     
		$this->display();
    }
	
  //登出页面
  public function logout() {
    
    // 销毁session
    session('[destroy]');
    $this->redirect('User/Index/index', array() , 0, '');
  }	
/*
密码验证
*/
	public function oper(){
	
		$username = I('post.username');
		$psw = I('post.psw');
		
		// 查询用户记录
		$user = M('tbuserinformation')->field('nuserid,cpassword,cname')->where(array(
		'nuserid' => $username,
		))->find();		
		
		if (empty($user)) {
			echo 1;
			return;
		}
		if (!CheckPassword($psw,$user['cpassword'])) {		
			echo 2;				
		}else{
			echo 3;
			
			session('is_login','yes');
			session('UserId',$username);
		}
	
		
	
		
	}
}